import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/widgets/add_image_widget.dart';

import '../../viewmodel/upload_elder_case_view_model.dart';

class UploadElderCasePage extends BaseStatefulMvvmWidget{
  dynamic elderId;
  final List<String> images;

  UploadElderCasePage({this.images = const [],required this.elderId});

  @override
  State<StatefulWidget> createState() => _UploadElderCaseState();

}

class _UploadElderCaseState extends BaseMvvmState<UploadElderCaseViewModel,UploadElderCasePage>{



  @override
  Widget buildLoadingContentView() {
    return AddImageWidget((files) {
      setState(() {
        viewModel.images = files;
      });
      // if(files.isEmpty){
      //   Go().pop();
      // }
    },files: viewModel.images!,cameramsg: "拍摄上传健康档案照片，需要申请您的相机权限照片",photomsg: "从相册选取健康档案，需要您的相册权限",);
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      appBar: AppBar(title: Text("上传健康档案"),
      actions: [
        TextButton(onPressed: (){
          viewModel.uploadCase();
        }, child: Text('上传'))
      ],),
      body: loadingContentWidget,
    );
  }

  @override
  UploadElderCaseViewModel createViewModel() {
    return UploadElderCaseViewModel(context,images: widget.images,elderId: widget.elderId);
  }

  @override
  void onRetryClick() {
  }

}